package com.tekj.cxqcb.view.Module.adapter;

import android.support.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tekj.cxqcb.R;
import com.tekj.cxqcb.operation.resultBean.ApiShopServiceTypeBean;
import com.tekj.cxqcb.operation.resultBean.SelectByLevelBean;

import java.util.List;

public class StoreTypeAdapter extends BaseQuickAdapter<ApiShopServiceTypeBean.DataBean, BaseViewHolder> {

    public StoreTypeAdapter(@Nullable List<ApiShopServiceTypeBean.DataBean> data) {
        super(R.layout.item_new_store_details, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, ApiShopServiceTypeBean.DataBean item) {

        helper.setText(R.id.tv_type_name, item.getTypeName());

        helper.setBackgroundColor(R.id.ll_bg,
                mContext.getResources().getColor(item.isSelection() ? R.color.white : R.color.color_f8f8f8));

    }

    public void setSelection(int p) {
        for (int i = 0; i < mData.size(); i++) {
            mData.get(i).setSelection(i == p);
        }
        notifyDataSetChanged();
    }

}
